/**
 * Copyright (c) 2020-2021 浦东大爷 All rights reserved.
 * 机会永远都是留给有准备的人
 */
package com.job.moudle2.task3;

import java.math.BigDecimal;

/**
 * @author: gitwo
 * @date: 2020-11-12
 * @description:
 */
public class TalkSetMeal extends SetMeal implements TalkServiceimpl{


    private int talkTimes;
    private int messageCount;

    public TalkSetMeal() {
    }

    public TalkSetMeal(int talkTimes, int messageCount, BigDecimal monthlyRates) {
        super(monthlyRates);
        this.talkTimes = talkTimes;
        this.messageCount = messageCount;
    }

    public int getTalkTimes() {
        return talkTimes;
    }

    public void setTalkTimes(int talkTimes) {
        this.talkTimes = talkTimes;
    }

    public int getMessageCount() {
        return messageCount;
    }

    public void setMessageCount(int messageCount) {
        this.messageCount = messageCount;
    }

    @Override
    public void show() {
        System.out.println("通话套餐信息：\n\t通话时长：" + talkTimes + "\t短信条数：" + messageCount + "\t每月资费：" + getMonthlyRates());
    }

    /**
     * 模拟通话的时候的动作
     * 传入这个用户，以及通话产生的分钟数，扣除用户的通话时间，同时把统计加上去
     */
    @Override
    public void talk(int talkTime, SIMCard simCard) {
        System.out.println("模拟打电话的过程");
        simCard.setTalkTimes(simCard.getTalkTimes() - talkTime);
        System.out.println("本次通话" + talkTime + "分钟， 套餐剩余通话分钟：" + simCard.getTalkTimes());
        UserConsumption userConsumption = UserConsumption.getInstance();
        userConsumption.addTalkTimes(talkTime);
    }
}
